//
//  YFWebViewController.swift
//  仿新浪微博
//
//  Created by 杨帆 on 16/7/11.
//  Copyright © 2016年 杨帆. All rights reserved.
//

import UIKit

class YFWebViewController: YFBaseViewController {

    private lazy var webView = UIWebView(frame: UIScreen.main().bounds)
    
    // 要加载的URL字符串
    var urlString: String? {
    
        didSet {
        
            guard let urlString = urlString,
                url = URL(string: urlString)
                else {
                    return
            }
            
            webView.loadRequest(URLRequest(url: url))
        }

    }

}

extension YFWebViewController {

    override func setupTableView() {
        
        // 设置标题
        navItem.title = "网页"
        
        // 设置webView
        view.insertSubview(webView, belowSubview: navigationBar)
        
        webView.backgroundColor = UIColor.white()
        
        // 设置contentInset
        webView.scrollView.contentInset.top = navigationBar.bounds.height
    }
}
